package com.example.learn.hwod;

import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Collectors;

public class _23预定酒店 {
    static class Hotel{
        int price;
        int dis;
        public Hotel(int price, int dis){
            this.price = price;
            this.dis = dis;
        }

        public int getPrice() {
            return price;
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] split = sc.nextLine().split(" ");
        int n = Integer.parseInt(split[0]);
        int number = Integer.parseInt(split[1]);
        int target = Integer.parseInt(split[2]);
        List<Hotel> collect = Arrays.stream(sc.nextLine().split(" ")).map(x -> {
            int i = Integer.parseInt(x);
            Hotel hotel = new Hotel(i, Math.abs(target - i));
            return hotel;
        }).sorted((a, b) -> {
            if (a.dis - b.dis==0) {
                return a.price - b.price;
            }else return a.dis-b.dis;
        }).collect(Collectors.toList());

        String result = collect.subList(0, number ).stream().sorted((a, b) -> a.price - b.price).map(x -> String.valueOf(x.getPrice())).collect(Collectors.joining(" "));
        System.out.println(result);


    }
}
